package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Connect {
	
	private static final String URL="jdbc:sqlserver://localhost:1433;databasename=FlowerStore;user=sa;password=150391";
	
	public Connect(){}
	
	public Connection getConnection()
	{
		
		Connection connection=null;
		int count=1;
		while(connection==null){
			try {
				Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
				connection=DriverManager.getConnection(URL);
			} catch (ClassNotFoundException e) {
				System.out.println("Ket noi driver that bai");
				e.printStackTrace();
				break;
			} catch (SQLException e) {
				System.out.println("Ket noi sql that bai");
				e.printStackTrace();
				break;
			}
			count++;
		}
		return connection;
	}
	
	public static void main(String[] args) {
		Connect cn=new Connect();
		System.out.println(cn.getConnection().toString());
	}
}
